<template>
  <div class="consultation-detail-wrapper" v-meta-title="data.informationTitle">
    <div @click="toMain">
      <mt-header fixed title="校园资讯" style="-webkit-transform: translate3d(0,0,0);">
        <mt-button icon="back" slot="left" @click.stop="goBack">返回</mt-button>
        <!-- <mt-button icon="more" slot="right"></mt-button> -->
      </mt-header>
    </div>

    <mt-loadmore style="padding-bottom: 12px;">
      <div class="title" style="margin-top: 40px;">{{ data.informationTitle }}</div>
      <div class="publish">
        <p>{{ data.publishSchool }}</p>
        <div>{{ data.publishTime }}</div>
        <div>浏览数:{{ data.browseNum }}</div>
      </div>

      <div class="content" v-html="data.content"></div>
    </mt-loadmore>

    <div id="SOHUCS" :sid="id"></div>
  </div>
</template>


<script>
import axios from '@/api/axiosApi'
import { mapGetters } from 'vuex'

export default {
  data () {
    return {
      data: {
        metaTitle: 'QD校园',
        id: ''
      }
    }
  },
  computed: {
    ...mapGetters([
      'personInfo'
    ])
  },
  methods: {
    toMain () {
      this.$router.replace({
        path: '/',
        query: this.$route.query
      })
    },
    goBack () {
      this.$router.go(-1)
    },
    _getDetail (id) {
      const _self = this
      const openId = localStorage.getItem('openId')
      axios.post('/commons/findActivityDetail', {
        id: id,
        studentId: openId,
        type: 3
      }, (data) => {
        _self.data = data
      })
    }
  },
  watch: {
    '$route'(to, from) {
      if (to.name === 'consultationDetail') {
        const id = this.$route.params.contentId
        if (id) {
          this._getDetail(id)
        }
      }
    }
  },
  created () {
    const id = this.$route.params.contentId
    this.id = id
    if (id) {
      this._getDetail(id)
    }
  }
}
</script>

<style>
.consultation-detail-wrapper .content p, .consultation-detail-wrapper .content img {
  word-break:break-word;
  width: 100%;
}
</style>

<style lang="stylus" scoped>
@import '~assets/stylus/variable.styl';

.consultation-detail-wrapper {
  overflow: hidden;
  padding: 15px;

  .title {
    font-size: 21px;
    font-weight: bold;
    text-align: center;
    margin-top: 15px;
  }

  .publish {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    height: 35px;
    line-height: 35px;

    div {
      color: $color-text-dark;
      font-size: 15px;
    }
  }

  .content {
    font-size: 16px;
    margin-top: 12px;
    line-height: 1.4rem;
  }

  p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
</style>
